package com.example.mqspring.rabiitmqbasicleverone.rabbitmqTopic;

import com.example.mqspring.utils.RabbitMqUtil;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import lombok.Data;
@Data
public class Producer {


    private String myexchange = "MY_TOPIC_EXCHANGE";
    private String ROUTKEY = "M_EXCHANGE_KEY";
    private String message = "我来发送一次topic消息";
    public void sendMessage(Channel channel, String Myexchange, String routkey, String message) throws Exception {
        RabbitMqUtil.sendMessage(channel,"topic",Myexchange,routkey,message);
    }
    public static void main(String[] args) {
        Producer producer = new Producer();
        Connection connection = RabbitMqUtil.createConnection();
        Channel channel = null;
        try {
            channel = connection.createChannel();
            producer.sendMessage(channel,producer.getMyexchange(),producer.ROUTKEY,producer.message);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
